package chen.web.config;

public class GetBackPasswordConfig extends Config{

	private static final String ExpritedPropertyName = "expired";
	private static final String EmailSubjectPropertyName = "emailSubject";
	private static final String EmailContentPropertyName = "emailContent";
	private static final String MaxTimesPropertyName = "maxTimes";
	
	private int expired;	//验证码过期时间，单位秒
	private String emailSubject; //邮件主题
	private String emailContent; //邮件内容
	private int maxTimes;			//每天最多发送邮件次数
	
	private GetBackPasswordConfig(Builder builder){
		this.expired = builder.expired;
		this.emailSubject = builder.emailSubject;
		this.emailContent = builder.emailContent;
		this.maxTimes = builder.maxTimes;
	}
	
	public static class Builder{
		private int expired;
		private String emailSubject; 
		private String emailContent; 
		private int maxTimes;		
		
		public GetBackPasswordConfig build(){
			return new GetBackPasswordConfig(this);
		}
		
		public Builder expired(int expired){
			this.expired = expired;
			return this;
		}
		
		public Builder emailSubject(String emailSubject){
			this.emailSubject = emailSubject;
			return this;
		}
		
		public Builder emailContent(String emailContent){
			this.emailContent = emailContent;
			return this;
		}
		
		public Builder maxTimes(int maxTimes){
			this.maxTimes = maxTimes;
			return this;
		}
	}

	@Override
	public void persist() {
		// TODO Auto-generated method stub
		this.setProperty(ExpritedPropertyName, String.valueOf(this.expired));
		this.setProperty(EmailSubjectPropertyName, this.emailSubject);
		this.setProperty(EmailContentPropertyName, this.emailContent);
		this.setProperty(MaxTimesPropertyName, String.valueOf(this.maxTimes));
	}
	
	@Override
	protected void load(){
		this.expired = Integer.parseInt(this.getProperty(ExpritedPropertyName));
		this.emailSubject = this.getProperty(EmailSubjectPropertyName);
		this.emailContent = this.getProperty(EmailContentPropertyName);
		this.maxTimes = Integer.parseInt(this.getProperty(MaxTimesPropertyName));
	}
}
